import loading from './components/packages/loading'
import modal from './components/packages/modal'
import spinner from './components/packages/spinner'
import popup from './components/packages/popup'
import picker from './components/packages/picker'
import datePicker from './components/packages/date-picker'
import lazyLoad from './components/packages/lazy-load'
import button from './components/packages/button'
import dialog from './components/packages/dialog'
import Toast from './components/packages/toast'
import Style from './components/packages/style'

const install = function (Vue, opts = {}) {
  /* istanbul ignore if */
  if (install.installed) return

  Vue.component(modal.name, modal)
  spinner.install(Vue)
  popup.install(Vue)
  button.install(Vue)
  picker.install(Vue)
  datePicker.install(Vue)
  lazyLoad.install(Vue)
  loading.install(Vue)
  dialog.install(Vue)
  Style.install(Vue)
  Vue.$toast = Vue.prototype.$toast = Toast
  Vue.prototype.$showdownModal = modal
}

/* istanbul ignore if */
if (typeof window !== 'undefined' && window.Vue) {
  install(window.Vue)
}

export default {
  install: install
}
